package NWish.properties
{
	import NWish.Misc;
	import NWish.properties.object3ds.*;
	
	import org.aswing.JToggleButton;

	public class Object3DPropertiesTypes
	{
		private var _window;
		
		private var _types:Array;
		
		public function Object3DPropertiesTypes(_parent,window)
		{
			//
			_window = window;
			
			//
			var object3d:JToggleButton = new JToggleButton('     object     ');
			object3d.x = 5;
			object3d.y = 2;
			object3d.pack();
			object3d.height = 16;
			_window.buttonGroup.append(object3d);
			_window.panel.append(object3d);
			object3d.addActionListener(onObject3d);
			
			
			//
			_types = 	
			[new CubeProperties(_parent)
			,new PlaneProperties(_parent)
			,new SphereProperties(_parent)
			,new RegularPolygonProperties(_parent)
			,new ConeProperties(_parent)
			,new CylinderProperties(_parent)
			,new MeshLoaderProperties(_parent)
			,new Sprite3DProperties(_parent)
			,new SkyBoxProperties(_parent)
			,new DirectionalLightProperties(_parent)
			,new PointLightProperties(_parent)
			,new ObjectContainer3DProperties(_parent)
			,new Sound3DProperties(_parent)
			,new Camera3DProperties(_parent)
			,new Scene3DProperties()
			,new View3DProperties(_parent)
			];
			
			//
			object3d.doClick();
		}
		
		private function onObject3d(e)
		{
			if((e.target as JToggleButton).isSelected())
			{
				_window.currPropertiesTypes = this;
				//subMeshs.visible = false;
			}
		}
		
		public function get types()
		{
			return _types;
		}
		
		public function getPropertiesType(obj:Object)
		{
			for each (var p:Properties in _types)
			{
				if(Misc.isClass(obj,p.type))
				{
					return p;
				}
			}
			return null;
		}
		
		public function addPropertiesType(pt)
		{
			_types.push(pt);
		}
		
		public function toString()
		{
			return 'object properties';
		}
	}
	
}